#!/usr/bin/env python3

# Copyright (c) 2005-2014 Fpemud <fpemud@sina.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import os
from utils import Util
from config import Config


class Category:

    def __init__(self):
        self._productId = None
        self._bDownloadLangPack = False
        self._bDownloadUpdate = False
        self._bDownloadDrivers = False

    def get_category_id(self):
        return "winxp"

    def get_category_name(self):
        return "Microsoft Windows XP"

    def get_category_cmdline_option_description(self):
        buf = ""
        buf += '--language-pack: download language pack.\n'
        buf += '--updates: download all updates.\n'
        buf += '--drivers: download all drivers.\n'
        return buf

    def set_product_and_parse_cmdline(self, productId, argv, c, dieFunc):
        self._productId = productId

        while len(argv) > c:
            if argv[c] == "--language-pack":
                if "tabletpc" in productId:
                    dieFunc("Product %s does not support language pack." % (self._productId))
                self._bDownloadLangPack = True
                c += 1
                continue
            if argv[c] == "--updates":
                if "tabletpc" in productId:
                    dieFunc("Product %s does not support updates." % (self._productId))
                self._bDownloadUpdate = True
                c += 1
                continue
            elif argv[c] == "--drivers":
                if "tabletpc" in productId:
                    dieFunc("Product %s does not support drivers." % (self._productId))
                self._bDownloadDrivers = True
                c += 1
                continue
            else:
                break

        return c

    def get_product_id_list(self):
        ret = []

        ret += [
            "windows-xp-home.x86.ar",
            "windows-xp-home.x86.cs",
            "windows-xp-home.x86.da",
            "windows-xp-home.x86.de",
            "windows-xp-home.x86.el",
            "windows-xp-home.x86.en",
            "windows-xp-home.x86.es",
            "windows-xp-home.x86.fi",
            "windows-xp-home.x86.fr",
            "windows-xp-home.x86.he",
            "windows-xp-home.x86.hu",
            "windows-xp-home.x86.it",
            "windows-xp-home.x86.ja",
            "windows-xp-home.x86.ko",
            "windows-xp-home.x86.nl",
            "windows-xp-home.x86.no",
            "windows-xp-home.x86.pl",
            "windows-xp-home.x86.pt-br",
            "windows-xp-home.x86.pt-pt",
            "windows-xp-home.x86.ru",
            "windows-xp-home.x86.sv",
            "windows-xp-home.x86.tr",
            "windows-xp-home.x86.zh-cn",
            "windows-xp-home.x86.zh-hk",
            "windows-xp-home.x86.zh-tw",
        ]

        ret += [
            "windows-xp-home-n.x86.cs",
            "windows-xp-home-n.x86.da",
            "windows-xp-home-n.x86.de",
            "windows-xp-home-n.x86.el",
            "windows-xp-home-n.x86.en",
            "windows-xp-home-n.x86.es",
            "windows-xp-home-n.x86.fi",
            "windows-xp-home-n.x86.fr",
            "windows-xp-home-n.x86.hu",
            "windows-xp-home-n.x86.it",
            "windows-xp-home-n.x86.ko",
            "windows-xp-home-n.x86.nl",
            "windows-xp-home-n.x86.no",
            "windows-xp-home-n.x86.pl",
            "windows-xp-home-n.x86.pt-pt",
            "windows-xp-home-n.x86.sv",
        ]

        ret += [x.replace("home", "professional") for x in ret]

        ret += [x.replace("professional.x86", "professional-vl.x86") for x in ret if "professional.x86" in x]
        ret += [x.replace("professional-n.x86", "professional-n-vl.x86") for x in ret if "professional-n.x86" in x]

        ret += [
            "windows-xp-professional-vl.x86_64.en",
        ]

        ret += [
            "windows-xp-tabletpc-vl.en",
        ]

        return ret

    def get_product_description(self, product_id):
        ret = ""

        if "tabletpc" not in product_id:
            edition, arch, lang = product_id.split(".")

            d = {
                "windows-xp-home":              "Microsoft Windows XP Home",
                "windows-xp-home-n":            "Microsoft Windows XP Home N",
                "windows-xp-professional":      "Microsoft Windows XP Professional (Retail)",
                "windows-xp-professional-n":    "Microsoft Windows XP Professional N (Retail)",
                "windows-xp-professional-vl":   "Microsoft Windows XP Professional (VL)",
                "windows-xp-professional-n-vl": "Microsoft Windows XP Professional N (VL)",
            }
            ret += d[edition]
            ret += ", "

            d = {
                "x86":    "X86",
                "x86_64": "X86_64",
            }
            ret += d[arch]
            ret += ", "

            d = {
                "pt-br": "pt-BR",
                "pt-pt": "pt-PT",
                "zh-cn": "zh-Hans",
                "zh-hk": "zh-HK",
                "zh-tw": "zh-TW",
            }
            if lang in d:
                ret += d[lang]
            else:
                ret += lang
        else:
            edition, lang = product_id.split(".")

            d = {
                "windows-xp-tabletpc-vl": "Microsoft Windows XP Tablet PC (VL)",
            }
            ret += d[edition]
            ret += ", "

            ret += lang

        return ret

    def download(self, cacheDir, destDir):
        if "tabletpc" not in self._productId:
            # download product
            localProductFile = None
            if True:
                url = _WinXP.get_product_url(self._productId)
                fn = os.path.basename(url)
                localProductFile = os.path.join(cacheDir, fn)

                chksum = _WinXP.get_product_digest(self._productId)
                if chksum is not None:
                    algo, chksum = chksum

                Util.checkAndFetchHttp(localProductFile, [url], chksum, algo, Config.checksumMaxTries, Config.verboseLevel)

            # download language pack
            localLangPackFile = None
            if self._bDownloadLangPack:
                url = _WinXP.get_lang_pack_url()
                fn = os.path.basename(url)
                localLangPackFile = os.path.join(cacheDir, fn)

                Util.checkAndFetchHttp(localLangPackFile, [url], None, None, Config.checksumMaxTries, Config.verboseLevel)

            # copy to destDir
            if True:
                finalFile = os.path.join(destDir, self._productId + ".iso")
                Util.copyFile(localProductFile, finalFile, os.getuid(), os.getgid())
            if localLangPackFile is not None:
                finalFile = os.path.join(destDir, "language-pack.iso")
                Util.copyFile(localLangPackFile, finalFile, os.getuid(), os.getgid())
        else:
            urlList = _WinXP.get_product_url(self._productId)
            fnList = [os.path.basename(url) for url in urlList]
            localProductFileList = [os.path.join(cacheDir, fn) for fn in fnList]

            chksumList = _WinXP.get_product_digest(self._productId)

            for i in range(0, len(urlList)):
                Util.checkAndFetchHttp(localProductFileList[i], [urlList[i]], chksumList[i][1], chksumList[i][0], Config.checksumMaxTries, Config.verboseLevel)

            for i in range(0, len(urlList)):
                finalFile = os.path.join(destDir, self._productId + "cd%d.iso" % (i + 1))
                Util.copyFile(localProductFileList[i], finalFile, os.getuid(), os.getgid())


class _WinXP:

    @staticmethod
    def get_product_url(productId):
        # from "https://archive.org/details/windows-xp-all-sp-msdn-iso-files-en-de-ru-tr-x86-x64"
        if productId == "windows-xp-home.x86.en":
            # important
            return "https://archive.org/download/windows-xp-all-sp-msdn-iso-files-en-de-ru-tr-x86-x64/en_windows_xp_home_with_service_pack_3_x86_cd_x14-92413.iso"
        if productId == "windows-xp-professional.x86.en":
            # important
            return "https://archive.org/download/windows-xp-all-sp-msdn-iso-files-en-de-ru-tr-x86-x64/en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso"
        if productId == "windows-xp-professional.x86.tr":
            return "https://archive.org/download/windows-xp-all-sp-msdn-iso-files-en-de-ru-tr-x86-x64/tr_windows_xp_professional_with_service_pack_3_x86_cd_x14-80496.iso"
        if productId == "windows-xp-professional-vl.x86.de":
            return "https://archive.org/download/windows-xp-all-sp-msdn-iso-files-en-de-ru-tr-x86-x64/de_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73985.iso"
        if productId == "windows-xp-professional-vl.x86.en":
            # important
            return "https://archive.org/download/windows-xp-all-sp-msdn-iso-files-en-de-ru-tr-x86-x64/en_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73974.iso"
        if productId == "windows-xp-professional-vl.x86.tr":
            return "https://archive.org/download/windows-xp-all-sp-msdn-iso-files-en-de-ru-tr-x86-x64/tr_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74085.iso"
        if productId == "windows-xp-professional-vl.x86.ru":
            return "https://archive.org/download/windows-xp-all-sp-msdn-iso-files-en-de-ru-tr-x86-x64/ru_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74146.iso"
        if productId == "windows-xp-professional-vl.x86_64.en":
            # important
            return "https://archive.org/download/windows-xp-all-sp-msdn-iso-files-en-de-ru-tr-x86-x64/en_win_xp_pro_x64_with_sp2_vl_x13-41611.iso"
        if productId == "windows-xp-tabletpc-vl.en":
            return [
                "https://archive.org/download/windows-xp-all-sp-msdn-iso-files-en-de-ru-tr-x86-x64/en_win_xp_tabletpc_2005_disc1_vl.iso",
                "https://archive.org/download/windows-xp-all-sp-msdn-iso-files-en-de-ru-tr-x86-x64/en_win_xp_tabletpc_2005_disc2_vl.iso",
            ]

        # from https://windowslay.com/windows-xp-sp3-iso-download/
        # if productId == "windows-xp-professional.x86.en-us":
        #     return "https://files.windowslay.com/en_windows_xp_professional_sp3_Nov_2013_Incl_SATA_Drivers.iso"     # FIXME: not origian disk

        # from https://windowslay.com/windows-xp-professional-64-bit-iso-download
        # if productId == "windows-xp-professional.x86_64.en-us":
        #     return "https://files.windowslay.com/en_windows_xp_professional_64-bit_dvd.iso"

        assert False

    @staticmethod
    def get_product_digest(productId):
        # from "https://gist.githubusercontent.com/anonymous/81b7753f39baf450781195bcfc72259e/raw"
        dataDict = {}
        dataDict.update({
            "windows-xp-home.x86.ar":    "5016d44562767022ef4a2444cf30b9bd0560ea26 *ar_windows_xp_home_with_service_pack_3_x86_cd_x14-92405.iso",
            "windows-xp-home.x86.cs":    "a173389f2386bd189fe95f80f78a1fa8750e665b *cs_windows_xp_home_with_service_pack_3_x86_cd_x14-92410.iso",
            "windows-xp-home.x86.da":    "68cba7defac3773916b730c1567b4d94d9fed615 *da_windows_xp_home_with_service_pack_3_x86_cd_x14-92411.iso",
            "windows-xp-home.x86.de":    "9669bb7e5a9cb8a1f6fa373f36cc5c8f9cc0111f *de_windows_xp_home_with_service_pack_3_x86_cd_x14-92416.iso",
            "windows-xp-home.x86.el":    "19a887f312cbee84b1cde1d6b95b8e93485c0ec9 *el_windows_xp_home_with_service_pack_3_x86_cd_x14-92417.iso",
            "windows-xp-home.x86.en":    "5a6b959ad24d15dc7ebd85e501b83d105d1b37c6 *en_windows_xp_home_with_service_pack_3_x86_cd_x14-92413.iso",
            "windows-xp-home.x86.es":    "4ee3f273acd2d9137901ee6c7528201e4f216dfe *es_windows_xp_home_with_service_pack_3_x86_cd_x14-92427.iso",
            "windows-xp-home.x86.fi":    "53fa2e0f2ac4947a66070c5c67403c8fe0fd88dd *fi_windows_xp_home_with_service_pack_3_x86_cd_x14-92414.iso",
            "windows-xp-home.x86.fr":    "7ac447798dca6fe69667a6848de7a44a83bd5c4f *fr_windows_xp_home_with_service_pack_3_x86_cd_x14-92415.iso",
            "windows-xp-home.x86.he":    "7891e5abdbb5c621da07a0fa7b707947364e27a2 *he_windows_xp_home_with_service_pack_3_x86_cd_x14-92418.iso",
            "windows-xp-home.x86.hu":    "34d3ea6d38545b2788772865cfbbbb0f2c40ea27 *hu_windows_xp_home_with_service_pack_3_x86_cd_x14-92419.iso",
            "windows-xp-home.x86.it":    "b77da80213cab73e7d5829df3f55b43e9516e6a5 *it_windows_xp_home_with_service_pack_3_x86_cd_x14-92420.iso",
            "windows-xp-home.x86.ja":    "a907477482a45f0c7617e384b1b8a69802bc815c *ja_windows_xp_home_with_service_pack_3_x86_cd_x14-92421.iso",
            # "windows-xp-home.x86.ko": "e81c5e6e7aa34e32091538462d963488dc08ef66 *ko_windows_xp_home_k_with_service_pack_3_x86_cd_x14-92387.iso",
            "windows-xp-home.x86.nl":    "59f08e21cf2475c1f732085f60687244b9ab31c8 *nl_windows_xp_home_with_service_pack_3_x86_cd_x14-92412.iso",
            "windows-xp-home.x86.no":    "93e8b5e8e52e20a66c73ea272fd5096d622565be *no_windows_xp_home_with_service_pack_3_x86_cd_x14-92423.iso",
            "windows-xp-home.x86.pl":    "4d8e9b1debb9aed6c8b28a578fc47aa64eb6ec68 *pl_windows_xp_home_with_service_pack_3_x86_cd_x14-92424.iso",
            "windows-xp-home.x86.pt-br": "d33f588ca629e25f7885b2beddefa05a4b4c3ba7 *pt-br_windows_xp_home_with_service_pack_3_x86_cd_x14-92406.iso",
            "windows-xp-home.x86.pt-pt": "71e0bdff6123357ffd23111d299ba27f80336349 *pt-pt_windows_xp_home_with_service_pack_3_x86_cd_x14-92425.iso",
            "windows-xp-home.x86.ru":    "e573dcf620c4fc1080591982521092b02d3f12b0 *ru_windows_xp_home_with_service_pack_3_x86_cd_x14-92426.iso",
            "windows-xp-home.x86.sv":    "40314f062a4e13d80a5a0675235f73057f80bdd0 *sv_windows_xp_home_with_service_pack_3_x86_cd_x14-92428.iso",
            "windows-xp-home.x86.tr":    "67d8f3badb799076a6567d3a869a8bd474fbce28 *tr_windows_xp_home_with_service_pack_3_x86_cd_x14-92429.iso",
            "windows-xp-home.x86.zh-cn": "f15ef466b1d87b1ffdadc246b8ce82287bd15ed5 *zh-hans_windows_xp_home_with_service_pack_3_x86_cd_x14-92408.iso",
            "windows-xp-home.x86.zh-hk": "393e12fe84bf209048c25514932c4ca9f3a64969 *zh-hk_windows_xp_home_with_service_pack_3_x86_cd_x14-92407.iso",
            "windows-xp-home.x86.zh-tw": "5f26037e36855b685011f257e06f8360ccc12698 *zh-tw_windows_xp_home_with_service_pack_3_x86_cd_x14-92409.iso",
        })
        dataDict.update({
            "windows-xp-home-n.x86.cs":    "e48c05dd867e3eebcfe02faca6c8bd937a1f541c *cs_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92390.iso",
            "windows-xp-home-n.x86.da":    "551bd4934042a776f95d54b2cd07882dc980c691 *da_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92391.iso",
            "windows-xp-home-n.x86.de":    "eeed89e196e23c707c9e3b990f3b3ff57b32de10 *de_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92396.iso",
            "windows-xp-home-n.x86.el":    "bc60b0cc3cd1030369e47b02d96f4972949144e3 *el_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92397.iso",
            "windows-xp-home-n.x86.en":    "f43b5bad8db60a25bb696183153ef856af839573 *en_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92393.iso",
            "windows-xp-home-n.x86.es":    "19b6bb5f77ed7c188e6bf9217492c9c560ac00b2 *es_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92403.iso",
            "windows-xp-home-n.x86.fi":    "e4be138cc54494383bbfd115880f36c22a3c435e *fi_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92394.iso",
            "windows-xp-home-n.x86.fr":    "ae398bbf0ad523cdaa3dec3a46d6981cd801a312 *fr_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92395.iso",
            "windows-xp-home-n.x86.hu":    "c32f5e77580b5ea6ca7fb60b84151aacdfcd4b5e *hu_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92398.iso",
            "windows-xp-home-n.x86.it":    "6400932fc089798f8f603d963e67f80862255f38 *it_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92399.iso",
            # "windows-xp-home-n.x86.ko":    "3c88bb786aefff3aabb90c02aa7d569c6aa459c2 *ko_windows_xp_home_kn_with_service_pack_3_x86_cd_x14-92389.iso",
            "windows-xp-home-n.x86.nl":    "17457065175e734b974a001b28cbb543573f9ba1 *nl_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92392.iso",
            "windows-xp-home-n.x86.no":    "8f49aa5e5b4a3ab6b889c9e93fa2d6c7bc3159f2 *no_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92400.iso",
            "windows-xp-home-n.x86.pl":    "95da470ea2572906a925c67c310246001f4dabe2 *pl_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92401.iso",
            "windows-xp-home-n.x86.pt-pt": "263d91111e6986f2ebe5b4a2d3dc41d0ee19771b *pt-pt_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92402.iso",
            "windows-xp-home-n.x86.sv":    "6a3729f644f38a953169010127909fa07d206944 *sv_windows_xp_home_n_with_service_pack_3_x86_cd_x14-92404.iso",
        })
        dataDict.update({
            "windows-xp-professional.x86.ar":    "22ae37b8f860d8ff7b30a82878e15931e41d1725 *ar_windows_xp_professional_with_service_pack_3_x86_cd_x14-80396.iso",
            "windows-xp-professional.x86.cs":    "9f4201afa36ae9f31ceaf4fc642e9764fcb5f536 *cs_windows_xp_professional_with_service_pack_3_x86_cd_x14-80416.iso",
            "windows-xp-professional.x86.da":    "9a6c10040e4c5ce1f8a2d60c7e0319edf8dceb92 *da_windows_xp_professional_with_service_pack_3_x86_cd_x14-80420.iso",
            "windows-xp-professional.x86.de":    "543b4a7c6779002a63614f09e5218056ee220af6 *de_windows_xp_professional_with_service_pack_3_x86_cd_x14-80444.iso",
            "windows-xp-professional.x86.el":    "254a501babf9716f9b3c9c73cadc4900a21fb73c *el_windows_xp_professional_with_service_pack_3_x86_cd_x14-80448.iso",
            "windows-xp-professional.x86.en":    "1c735b38931bf57fb14ebd9a9ba253ceb443d459 *en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso",
            "windows-xp-professional.x86.es":    "11ffce4604bbf627c5695e30c2238266e214c5db *es_windows_xp_professional_with_service_pack_3_x86_cd_x14-80488.iso",
            "windows-xp-professional.x86.fi":    "ce9bf0c9dc49efeba3b868e72baccb7f07ce63f9 *fi_windows_xp_professional_with_service_pack_3_x86_cd_x14-80436.iso",
            "windows-xp-professional.x86.fr":    "ffba78eb8e5a965a178ebd0cf354e9dd67dd5064 *fr_windows_xp_professional_with_service_pack_3_x86_cd_x14-80440.iso",
            "windows-xp-professional.x86.he":    "be5790b582368c5c3c7170760d2b578f22da76cb *he_windows_xp_professional_with_service_pack_3_x86_cd_x14-80452.iso",
            "windows-xp-professional.x86.hu":    "90476edef22543d7e56c7d924b4c54a0aa86303b *hu_windows_xp_professional_with_service_pack_3_x86_cd_x14-80456.iso",
            "windows-xp-professional.x86.it":    "2ba80aa9de48c34b2ab488afda9666ba7f4aa963 *it_windows_xp_professional_with_service_pack_3_x86_cd_x14-80460.iso",
            "windows-xp-professional.x86.ja":    "3125aaed8f40a5d8a10dbb959a03e39acc0d9fcb *ja_windows_xp_professional_with_service_pack_3_x86_dvd_x14-80464.iso",
            # "windows-xp-professional.x86.ko":    "cad31b63f9ec47aeaf6e3bded9d36425ddb3183a *ko_windows_xp_professional_k_with_service_pack_3_x86_cd_x14-92431.iso",
            "windows-xp-professional.x86.nl":    "ab323d40a96471675d12dde87bafd6fe0adc7141 *nl_windows_xp_professional_with_service_pack_3_x86_cd_x14-80424.iso",
            "windows-xp-professional.x86.no":    "b5dac6d279e55b434c41ba8d5f9697a65affdc09 *no_windows_xp_professional_with_service_pack_3_x86_cd_x14-80472.iso",
            "windows-xp-professional.x86.pl":    "595ca475f4a80b42704ae2fca9fb9042c37d5c49 *pl_windows_xp_professional_with_service_pack_3_x86_cd_x14-80476.iso",
            "windows-xp-professional.x86.pt-br": "32f376c2252849c81e1aa704838b01210c09ba96 *pt-br_windows_xp_professional_with_service_pack_3_x86_cd_x14-80400.iso",
            "windows-xp-professional.x86.pt-pt": "b8d34a720cbe3533ec45c870d1432fc568599e97 *pt-pt_windows_xp_professional_with_service_pack_3_x86_cd_x14-80480.iso",
            "windows-xp-professional.x86.ru":    "3686da63d3d3e8402eb43fe4bf29a58486eca6b3 *ru_windows_xp_professional_with_service_pack_3_x86_cd_x14-80484.iso",
            "windows-xp-professional.x86.sv":    "5060d593c8eac1d9875f5fd6f23691706abc5460 *sv_windows_xp_professional_with_service_pack_3_x86_cd_x14-80492.iso",
            "windows-xp-professional.x86.tr":    "ca1d57347afe6f9297e00381e0ae849fab8bc4f9 *tr_windows_xp_professional_with_service_pack_3_x86_cd_x14-80496.iso",
            "windows-xp-professional.x86.zh-cn": "69dbf131116760932dcf132ade111d6b45778098 *zh-hans_windows_xp_professional_with_service_pack_3_x86_cd_x14-80404.iso",
            "windows-xp-professional.x86.zh-hk": "48ac651e487a7368be50163263c4a3927fb4e869 *zh-hk_windows_xp_professional_with_service_pack_3_x86_cd_x14-80412.iso",
            "windows-xp-professional.x86.zh-tw": "ce63c1b72e058e121db9d58f81623da3e7401fbf *zh-tw_windows_xp_professional_with_service_pack_3_x86_cd_x14-80408.iso",
        })
        dataDict.update({
            "windows-xp-professional-n.x86.cs":    "72e589a3df3fee0835d4aa4287c9609eca03849c *cs_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92434.iso",
            "windows-xp-professional-n.x86.da":    "ebc027f05d963a3d06dd2e2e60b58975417a50db *da_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92435.iso",
            "windows-xp-professional-n.x86.de":    "4ae1ca5c436d13d72ab648f65eaa24c5811705a9 *de_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92447.iso",
            "windows-xp-professional-n.x86.el":    "fbf9b935d8e0fd2730081037e1551b1060227e1a *el_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92438.iso",
            "windows-xp-professional-n.x86.en":    "569b84652fd1b43505d9a8efe8667e456816880c *en_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92445.iso",
            "windows-xp-professional-n.x86.es":    "addf239025366741522b8d95e07701f143c727d2 *es_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92448.iso",
            "windows-xp-professional-n.x86.fi":    "a9957a9e171112f7f7057bafb744ecb52ef64251 *fi_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92437.iso",
            "windows-xp-professional-n.x86.fr":    "b8be9f2b29b4633a75cce2493483603609bea1c7 *fr_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92440.iso",
            "windows-xp-professional-n.x86.hu":    "28f726a85f436bae243b6473818ebf7ac0781d0e *hu_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92439.iso",
            "windows-xp-professional-n.x86.it":    "7d9513c84c2c6a731dd737f098a2ac83b4575f1a *it_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92477.iso",
            # "windows-xp-professional-n.x86.ko":    "6fd792c71bfa085273472a52aeee1757007c74fa *ko_windows_xp_professional_kn_with_service_pack_3_x86_cd_x14-92433.iso",
            "windows-xp-professional-n.x86.nl":    "40b461be9861dfb5d7959756005a9a27dcff0f5e *nl_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92436.iso",
            "windows-xp-professional-n.x86.no":    "a963adaa936e91c210c8660b21c14b950206ab5d *no_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92441.iso",
            "windows-xp-professional-n.x86.pl":    "0b78c027b6dba5d85b00dc54cf8b3916c5c6f9af *pl_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92442.iso",
            "windows-xp-professional-n.x86.pt-pt": "1bef6d82a27c78201562fe7e34c53dec348b745a *pt-pt_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92443.iso",
            "windows-xp-professional-n.x86.sv":    "be656c3e3828f535847b3d5759361e21f778b543 *sv_windows_xp_professional_n_with_service_pack_3_x86_cd_x14-92444.iso",
        })
        dataDict.update({
            "windows-xp-professional-vl.x86.ar":    "664e85af15aab89ae172fcdae9f3566a572bdab8 *ar_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74065.iso",
            "windows-xp-professional-vl.x86.cs":    "0fd3fbfa46d32f0d64a08d58f38c0c5e0ad2fc83 *cs_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73965.iso",
            "windows-xp-professional-vl.x86.da":    "def17b2c6ae30653ab39aec0f6566c36073bdafb *da_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73968.iso",
            "windows-xp-professional-vl.x86.de":    "55ad061ba1054da5ec800924b03337674e5a1262 *de_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73985.iso",
            "windows-xp-professional-vl.x86.el":    "3a108a5e542a9a4a75e69122ffb5933b5573db69 *el_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73988.iso",
            "windows-xp-professional-vl.x86.en":    "66ac289ae27724c5ae17139227cbe78c01eefe40 *en_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73974.iso",
            "windows-xp-professional-vl.x86.es":    "a47603256d7645a2f2788466153ffcd058f77c56 *es_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74009.iso",
            "windows-xp-professional-vl.x86.fi":    "af3708b0c037b69450a48b06a6db8a1104ef2b1c *fi_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73979.iso",
            "windows-xp-professional-vl.x86.fr":    "187fa9ee4e682fce20be6bc5bc092efcb6aafd11 *fr_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73982.iso",
            "windows-xp-professional-vl.x86.he":    "afc1245fdab4a4546ec672f87f25528eb114cf33 *he_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74143.iso",
            "windows-xp-professional-vl.x86.hu":    "e54efa1f033498436b76da9588bb6d31083ec0f8 *hu_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73991.iso",
            "windows-xp-professional-vl.x86.it":    "a04d68b0fc8b97eec1da9277e5d8126f318596dc *it_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73994.iso",
            "windows-xp-professional-vl.x86.ja":    "8719219c7a77756a904f4bb9fd2f32781f091c22 *ja_windows_xp_professional_with_service_pack_3_x86_dvd_vl_x14-74058.iso",
            # "windows-xp-professional-vl.x86.ko":    "aa00d0e694e0d885d654241d74e9654373f222eb *ko_windows_xp_professional_k_with_service_pack_3_x86_cd_vl_x14-87427.iso",
            "windows-xp-professional-vl.x86.nl":    "b82f76afcc45c0415e18fe79b8e41f9e0e17e67d *nl_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73971.iso",
            "windows-xp-professional-vl.x86.no":    "150ed1b6ae906ecd8e28b5fd583835e735c6ad08 *no_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74000.iso",
            "windows-xp-professional-vl.x86.pl":    "4838e23bd5f58b280627aa7848b165a5877e56c1 *pl_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74003.iso",
            "windows-xp-professional-vl.x86.pt-br": "015f13f28655957c93fe20d287ea62a50be64a95 *pt-br_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74137.iso",
            "windows-xp-professional-vl.x86.pt-pt": "be01482b44a70384c84a1c3d174547434ded071b *pt-pt_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74006.iso",
            "windows-xp-professional-vl.x86.ru":    "b7e0dd8b8832e4966e61a9ec3ccd9e7ef3ead1b3 *ru_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74146.iso",
            "windows-xp-professional-vl.x86.sv":    "a060aaccfedc7779fd003dccdb8ff711ce61edde *sv_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74012.iso",
            "windows-xp-professional-vl.x86.tr":    "ffe7b82b32ec55f0efae0eefd5f081b4e921119b *tr_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74085.iso",
            "windows-xp-professional-vl.x86.zh-cn": "d142469d0c3953d8e4a6a490a58052ef52837f0f *zh-hans_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74070.iso",
            "windows-xp-professional-vl.x86.zh-hk": "71a02d0b14da7ad12eaa0ec17187b80d114dfec1 *zh-hk_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74075.iso",
            "windows-xp-professional-vl.x86.zh-tw": "591b197429da2614abb6cb3915c20a5938a03321 *zh-tw_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74140.iso",
        })
        dataDict.update({
            "windows-xp-professional-n-vl.x86.cs":    "1f6dbcf02ccc22053033ac27502e73fb942c4923 *cs_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78061.iso",
            "windows-xp-professional-n-vl.x86.da":    "1b5477ea3a9b486cfee7394782d3b600ee3ef20f *da_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78077.iso",
            "windows-xp-professional-n-vl.x86.de":    "7398a8fb2d5ee6e49b24f2113a9397121279a9ed *de_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78162.iso",
            "windows-xp-professional-n-vl.x86.el":    "c519d8510e86db1d0db9b41d7863c7a4c8d57d13 *el_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78188.iso",
            "windows-xp-professional-n-vl.x86.en":    "a8143d52f60e4acc73d5f267f05ad833f034d453 *en_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78118.iso",
            "windows-xp-professional-n-vl.x86.es":    "168fd297590752620fb0d1c4892c5c860dee2637 *es_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78275.iso",
            "windows-xp-professional-n-vl.x86.fi":    "485b14314f539145d47ad68d36f68e83a56c4de9 *fi_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78137.iso",
            "windows-xp-professional-n-vl.x86.fr":    "2517604800afb4ba808e00cd2d063bcd907ee8f1 *fr_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78149.iso",
            "windows-xp-professional-n-vl.x86.hu":    "aeab795453e502c64600decb86ce3f7d5f6567bc *hu_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78199.iso",
            "windows-xp-professional-n-vl.x86.it":    "1ac66d8334f66c619799ac93dd4b77d3771d32ea *it_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78212.iso",
            # "windows-xp-professional-n-vl.x86.ko":    "723f0206cf09e5c8693de5eeaee7da849e734bc8 *ko_windows_xp_professional_kn_with_service_pack_3_x86_cd_vl_x14-78419.iso",
            "windows-xp-professional-n-vl.x86.nl":    "2981cca130f31419d01c04299099fbfc24f96bfe *nl_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78105.iso",
            "windows-xp-professional-n-vl.x86.no":    "87e3f8322e9e714a2eb1190f1723b6a247807155 *no_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78237.iso",
            "windows-xp-professional-n-vl.x86.pl":    "ce1aa76be58a4717faab056f8052c6c46c4f5f57 *pl_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78245.iso",
            "windows-xp-professional-n-vl.x86.pt-pt": "69d47f4cc875ace68765ce8c6def82508354b0a3 *pt-pt_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78262.iso",
            "windows-xp-professional-n-vl.x86.sv":    "f62dded9241a7b51bd5f72fc0c9b9ea8781d27e7 *sv_windows_xp_professional_n_with_service_pack_3_x86_cd_vl_x14-78286.iso",
        })
        if productId in dataDict:
            return ("sha1", dataDict[productId].split(" ")[0])

        # from "https://archive.org/details/windows-xp-all-sp-msdn-iso-files-en-de-ru-tr-x86-x64"
        if productId == "windows-xp-professional-vl.x86_64.en":
            return ("sha1", "cd9479e1dbad7f26b8bdcf97e4aa71cbb8de932b")
        if productId == "windows-xp-tabletpc-vl.en":
            return [
                ("sha1", "f85aca2ff6807647d5da6e0f6a3dcfd3cbbc617b"),
                ("sha1", "b12d44f2cdb342bd19d6d57a9e2b3b3050ba8011"),
            ]

        assert False

        # if productId == "windows-xp-professional.x86.en-us":
        #     return ("sha1", "6947e45f7eb50c873043af4713aa7cd43027efa7")

        # if productId == "windows-xp-professional.x86_64.en-us":
        #     return None

    @staticmethod
    def get_lang_pack_url():
        # from "https://archive.org/details/windows-xp-all-sp-msdn-iso-files-en-de-ru-tr-x86-x64"
        return "https://archive.org/details/windows-xp-mui-all-language-packs-sp0-sp1-sp2-sp3-x86-x64"
